import requests

# 设置目标 URL
url = "https://www.zhipin.com/wapi/zpjob/job/data/list?position=0&type=0&searchStr=&comId=&tagIdStr=&page=1&_=1738915980347"
headers = {
    "accept": "application/json, text/plain, */*",
    "accept-encoding": "gzip, deflate, br, zstd",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
    "cache-control": "no-cache",
    "content-type": "application/x-www-form-urlencoded",
    "cookie": "ab_guid=525c4c95-e8b8-410a-bb61-f39bb12ba26f; lastCity=101020100; Hm_lvt_194df3105ad7148dcf2b98a91b5e727a=1738909055; wt2=DmbXONVBHyENrV_wptNUuMaB4IxI6tpl5T1zPAB10GOs65ux8GaLqWF8W-B700D_RgFvtTFdJSIPaA2M6CeOkOA~~; wbg=1; zp_at=Xvgg4jIvjv0s-cKt0jYy3Iatpf1L_4Az-zU9kTGouzg~; __g=-; bst=V2RNInFef62VltVtRuzBQeLS2w7DrWzCo~|RNInFef62VltVtRuzBQeLS2w7DrQwSk~; __c=1738909109; __l=l=%2Fwww.zhipin.com%2Fweb%2Fchat%2Findex&r=&g=&s=3&friend_source=0&s=3&friend_source=0; __a=43058915.1738909030.1738909030.1738909109.8.2.2.8",
    "origin": "https://www.zhipin.com",
    "pragma": "no-cache",
    "referer": "https://www.zhipin.com/web/chat/index",
    "sec-ch-ua": "\"Not A(Brand\";v=\"8\", \"Chromium\";v=\"132\", \"Google Chrome\";v=\"132\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"macOS\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36",
    "x-requested-with": "XMLHttpRequest",
    "zp_token": "V2RNInFef62VltVtRuzBQeLS2w7DrWzCo~|RNInFef62VltVtRuzBQeLS2w7DrQwSk~"
}

# 发送 GET 请求
response = requests.get(url, headers=headers)

# 检查响应状态码
if response.status_code == 200:
    # 成功响应，解析响应的 JSON 数据
    response_data = response.json()

    # 获取数据部分
    if response_data.get('code') == 0:  # 确保接口返回的 code 为 0 表示成功
        job_data = response_data.get('zpData', {}).get('data', [])

        # 遍历数据并提取所需的字段
        for job in job_data:
            agent_id = '202501010001'
            job_id = job.get('encryptId', None)
            encrypt_job_id = job.get('encryptId', None)
            job_name = job.get('jobName', None)
            position_name = job.get('positionName', None)
            job_audit_status = job.get('jobAuditStatus', None)
            auth_token = "8486cf56-e9a6-4ea6-b877-af3334629159"
            job_status = job.get('jobStatus', None)
            show_type = job.get('showType', None)
            location_name = job.get('locationName', None)
            address_show_text = job.get('addressShowText', None)
            experience_name = job.get('experienceName', None)
            degree_name = job.get('degreeName', None)
            job_type_name = job.get('jobTypeName', None)
            paid_job_end_date = job.get('paidJobEndDate', None)
            brand_name = job.get('brandName', None)
            company_id = job.get('comId', None)
            low_salary = job.get('lowSalary', None)
            high_salary = job.get('highSalary', None)
            view_count = job.get('viewCount', None)
            concat_count = job.get('concatCount', None)
            interest_count = job.get('interestCount', None)
            add_time = job.get('addTime', None)
            update_time = job.get('updateTime', None)
            last_modify_time = job.get('lastModifyTime', None)
            salary_month = job.get('salaryMonth', None)
            free_experience = job.get('freeExperience', None)
            hot = job.get('hot', None)
            skill_require = job.get('skillRequire', None)

            # 输出获取所有的字段值
            print(f"agent_id: {agent_id}")
            print(f"job_id: {job_id}")
            print(f"encryptId: {encrypt_job_id}")
            print(f"jobName: {job_name}")
            print(f"positionName: {position_name}")
            print(f"jobAuditStatus: {job_audit_status}")
            print(f"jobStatus: {job_status}")
            print(f"showType: {show_type}")
            print(f"locationName: {location_name}")
            print(f"addressShowText: {address_show_text}")
            print(f"experienceName: {experience_name}")
            print(f"degreeName: {degree_name}")
            print(f"jobTypeName: {job_type_name}")
            print(f"paidJobEndDate: {paid_job_end_date}")
            print(f"brandName: {brand_name}")
            print(f"companyId: {company_id}")
            print(f"lowSalary: {low_salary}")
            print(f"highSalary: {high_salary}")
            print(f"viewCount: {view_count}")
            print(f"concatCount: {concat_count}")
            print(f"interestCount: {interest_count}")
            print(f"addTime: {add_time}")
            print(f"updateTime: {update_time}")
            print(f"lastModifyTime: {last_modify_time}")
            print(f"salaryMonth: {salary_month}")
            print(f"freeExperience: {free_experience}")
            print(f"hot: {hot}")
            print(f"skillRequire: {skill_require}")

            url = "http://192.168.0.110:7018/ai/job/add"
            headers = {"accept": "application/json, text/plain, */*"}
            data = {
                "agent_id": agent_id,
                "encrypt_job_id": encrypt_job_id,
                "job_id": job_id,
                "job_name": job_name,
                "position_name": position_name,
                "job_audit_status": job_audit_status,
                "auth_token": auth_token,
                "job_status": job_status,
                "show_type": show_type,
                "location_name": location_name,
                "address_show_text": address_show_text,
                "experience_name": experience_name,
                "degree_name": degree_name,
                "job_type_name": job_type_name,
                "brand_name": brand_name,
                "company_id": company_id,
                "low_salary": low_salary,
                "high_salary": high_salary,
                "view_count": view_count,
                "concat_count": concat_count,
                "interest_count": interest_count,
                "add_time": add_time,
                "update_time": update_time,
                "last_modify_time": last_modify_time,
                "salary_month": salary_month,
                "free_experience": free_experience,
                "hot": hot,
                "skill_require": skill_require,
                "paid_job_end_date": paid_job_end_date
            }
            "https://www.zhipin.com/wapi/zpjob/job/chatted/jobList"  # job_id字段上传接口
        # 发送 post 请求
        response = requests.post(url, headers=headers, data=data)

        # 检查响应状态码
        if response.status_code == 200:
            # 成功响应，解析响应的 JSON 数据
            response_data = response.json()
            print(response)

    else:
        print(f"请求失败，错误信息: {response_data.get('message')}")
else:
    print(f"请求失败，状态码: {response.status_code}")
